"use strict";
const common_vendor = require("../../../common/vendor.js");
const api_police_clock = require("../../../api/police/clock.js");
if (!Array) {
  const _easycom_uni_calendar2 = common_vendor.resolveComponent("uni-calendar");
  const _easycom_up_divider2 = common_vendor.resolveComponent("up-divider");
  const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
  (_easycom_uni_calendar2 + _easycom_up_divider2 + _easycom_up_toast2)();
}
const _easycom_uni_calendar = () => "../../../uni_modules/uni-calendar/components/uni-calendar/uni-calendar.js";
const _easycom_up_divider = () => "../../../node-modules/uview-plus/components/u-divider/u-divider.js";
const _easycom_up_toast = () => "../../../node-modules/uview-plus/components/u-toast/u-toast.js";
if (!Math) {
  (_easycom_uni_calendar + _easycom_up_divider + _easycom_up_toast)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "clockRecord",
  setup(__props) {
    const uToastRef = common_vendor.ref(null);
    const data = common_vendor.reactive({
      queryParam: {
        month: common_vendor.dayjs(/* @__PURE__ */ new Date()).format("YYYY-MM"),
        policeUserId: void 0
      },
      statData: {
        clockMonthCount: 0,
        //本月打卡次数
        clockMonthDayCount: 0,
        //本月打卡天数
        reportMonthCount: 0
        //本月报备天数
      },
      selected: []
    });
    const { queryParam, statData, selected } = common_vendor.toRefs(data);
    const getClockList = () => {
      common_vendor.index.showLoading({
        title: "加载中",
        mask: true
      });
      api_police_clock.listClockByTime(queryParam.value).then((res) => {
        common_vendor.index.hideLoading();
        const { data: data2 } = res;
        statData.value.clockMonthCount = data2.clockMonthCount;
        statData.value.clockMonthDayCount = data2.clockMonthDayCount;
        statData.value.reportMonthCount = data2.reportMonthCount;
        data2.monthVos = data2.monthVos ?? [];
        selected.value = data2.monthVos.map((item) => {
          let typeArr = [];
          if (item.clockStatus == 1) {
            typeArr = ["clock"];
          }
          if (item.reportStatus == 1) {
            typeArr = ["report"];
          }
          if (item.clockStatus == 1 && item.reportStatus == 1) {
            typeArr = ["clock", "report"];
          }
          item = {
            date: item.clockDay,
            type: typeArr
          };
          return item;
        });
      }).catch((err) => {
        common_vendor.index.hideLoading();
        uToastRef.value.show({
          type: "error",
          message: err
        });
      });
    };
    const changeMonth = (e) => {
      let monthStr = e.month < 10 ? "0" + e.month : e.month;
      queryParam.value.month = e.year + "-" + monthStr;
      getClockList();
    };
    const toClockDeatil = () => {
      common_vendor.index.navigateTo({
        url: `/subPages/police/clock/clockInfo?time=${queryParam.value.month}&userId=${queryParam.value.policeUserId}`
      });
    };
    const toReportDeatil = () => {
      common_vendor.index.navigateTo({
        url: `/subPages/police/report/reportInfo?time=${queryParam.value.month}&userId=${queryParam.value.policeUserId}`
      });
    };
    common_vendor.onLoad((options) => {
      if (options && options.userId) {
        queryParam.value.policeUserId = options.userId;
        getClockList();
      }
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.o(changeMonth),
        b: common_vendor.p({
          selected: common_vendor.unref(selected),
          showMonth: false
        }),
        c: common_vendor.p({
          lineColor: "#BBBBBB"
        }),
        d: common_vendor.t(common_vendor.unref(statData).clockMonthDayCount),
        e: common_vendor.t(common_vendor.unref(statData).clockMonthCount),
        f: common_vendor.o(toClockDeatil),
        g: common_vendor.t(common_vendor.unref(statData).reportMonthCount),
        h: common_vendor.o(toReportDeatil),
        i: common_vendor.sr(uToastRef, "066ae08c-2", {
          "k": "uToastRef"
        })
      };
    };
  }
});
wx.createPage(_sfc_main);
